home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / Net / Finger.php < prev    next >
PHP Script  |  2004-03-24  |  2KB  |  61 lines

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Sebastian Nohn <sebastian@nohn.net>                         |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Finger.php,v 1.5 2003/01/04 11:55:46 mj Exp $
  20. //
  21.  
  22. require_once 'PEAR.php';
  23. require_once 'Net/Socket.php';
  24.  
  25. /**
  26.  * PEAR's Net_Finger:: interface.
  27.  *
  28.  * Provides functions useful for Finger-Queries.
  29.  *
  30.  * @version $Revision: 1.5 $
  31.  * @author Sebastian Nohn <sebastian@nohn.net>
  32.  * @package Net
  33.  */
  34. class Net_Finger
  35. {
  36.  
  37.     /**
  38.      * Implements Net_Finger::query() function using PEAR's socket functions
  39.      *
  40.      * @param     string    $server The finger-server to query
  41.      * @param     string  $query    The finger database object to lookup
  42.      * @return     mixed              The data returned from the finger-server as string
  43.      *                          or a PEAR_Error ( see Net_Socket for error codes)
  44.      */   
  45.     function query($server, $query)
  46.     {
  47.         $socket = new Net_Socket;
  48.         if( PEAR::isError( $sockerror = $socket->connect($server, 79))) {
  49.             $data = new PEAR_Error( "Error connecting to $server ( Net_Socket says: ".
  50.                                     $sockerror->getMessage().")", $sockerror->getCode());
  51.         } else { 
  52.             $query .= "\n"; 
  53.             $socket->write($query); 
  54.             $data = $socket->read(16384); 
  55.             $socket->disconnect();
  56.         }         
  57.         return $data; 
  58.     } 
  59. ?>
  60.